/*
Date:20210530 17:26PM
key:经典层序遍历，记得放之前检查是不是null
 */
class Solution {
public:
    vector<int> levelOrder(TreeNode* root) 
    {
        vector<int>v;
        if(root==NULL){return v;}
        queue<TreeNode*>q;
        q.push(root);
        //cout<<q.front()->val;
        while(!q.empty())
        {
            v.push_back(q.front()->val);
            if(q.front()->left!=NULL)
            {
                q.push(q.front()->left);
            }
            if(q.front()->right!=NULL)
            {
                q.push(q.front()->right);
            }
            
            q.pop();
        }
        return v;
    }
};